package com.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.service.WeiboShareService;
import com.util.LoggerUtil;

@Controller
@RequestMapping("weiboShareController")
public class WeiboShareController {

	@Autowired
	private WeiboShareService weiboShareService;
	
	@RequestMapping(value="insertWeiboShare",method={RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public Map<String, Object> insertWeiboShare(String mId, String lId,
			String type, String uid, String location, String url,
			String created_at, String followersCount, String friendsCount,
			String statusesCount, String favouritesCount, String weiboNickname,HttpServletRequest request){
		JSONObject logs=JSONObject.fromObject(LoggerUtil.getParams(request));
		logs.put("mId", mId);
		logs.put("lId", lId);
		logs.put("type", type);
		logs.put("uid", uid);
		logs.put("location", location);
		logs.put("url", url);
		logs.put("created_at", created_at);
		logs.put("followersCount", followersCount);
		logs.put("friendsCount", friendsCount);
		logs.put("statusesCount", statusesCount);
		logs.put("favouritesCount", favouritesCount);
		logs.put("weiboNickname", weiboNickname);
		return weiboShareService.insertWeiboShare(mId, lId, type, uid, location, url, created_at, followersCount, friendsCount, statusesCount, favouritesCount, weiboNickname, logs);
	}
	
}